package com.yc.goods.biz;

import com.yc.entity.GoodsType;
import com.yc.goods.dao.GoodsTypeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GoodsTypeBizImpl implements GoodsTypeBiz{
    @Autowired
    private GoodsTypeDao goodsTypeDao;

    /**
     *查询所有
     * @return
     */
    @Override
    public List<GoodsType> findAll() {
        List<GoodsType> goodsTypes = goodsTypeDao.selectList(null);
        System.out.println(goodsTypes);
        return goodsTypes;
    }
    /**
     * 通过状态查询
     * @return
     */
    @Override
    public Map<String, Object> findByStatus(Integer status) {
        List<GoodsType> list=null;
        try {
            list=goodsTypeDao.findByStatus(status);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Map<String,Object> map =new HashMap<>();
        if (list == null || list.isEmpty()){
            map.put("code",500);
        }else {
            map.put("code",200);
        }
        map.put("data",list);
        return map;
    }
}
